// import { Fragment } from "react"
import type { FormProps } from 'antd';
import { Button, Form, Input } from 'antd';
import http from '@/apis/http';
type FieldType = {
  username?: string;
  password?: string;
  remember?: string;
};
export default function Main() {
  // return <Fragment>{a} /{wx}/</Fragment>;
  const onFinish: FormProps<FieldType>['onFinish'] = async (values) => {
    console.log('Success:', values);
    const { token, code } = await http.post('/login', values, {});
    if (token && code === 200) {
      window.localStorage.setItem('token', token);
      window.localStorage.setItem('code', code);
      // window.location.href = '/';
    }
  };

  const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (
    errorInfo
  ) => {
    console.log('Failed:', errorInfo);
  };
  return (
    <>
      <div className="mc mt80 w1200">
        <Form
          name="basic"
          labelCol={{ span: 3 }}
          initialValues={{ remember: true }}
          onFinish={onFinish}
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          <Form.Item<FieldType>
            label="用户名"
            name="username"
            rules={[{ required: true, message: '请输入用户名' }]}
          >
            <Input />
          </Form.Item>

          <Form.Item<FieldType>
            label="密码"
            name="password"
            rules={[{ required: true, message: '请输入密码' }]}
          >
            <Input.Password />
          </Form.Item>

          <Form.Item className="tc">
            <Button type="primary" htmlType="submit">
              登录
            </Button>
          </Form.Item>
        </Form>
      </div>
    </>
  );
}

// export default login();
